package com.financing.platform.dao.impl;

import java.sql.SQLException;
import java.util.Collections;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.financing.platform.dao.IProjectAccountDao;
import com.financing.platform.dto.ProjectAccountDTO;
import com.financing.platform.util.SqlName;


@Repository("projectAccountDaoImpl")
public class ProjectAccountDaoImpl extends BaseDaoImpl implements IProjectAccountDao {

	public int addProjectAccount(ProjectAccountDTO projectAccountDTO)
			throws SQLException {
		return (Integer) this.sqlMapClient.insert(SqlName.addProjectAccount,projectAccountDTO);
	}

	@SuppressWarnings("unchecked")
	public List<ProjectAccountDTO> queryProjectAccount(int projectId) {
		try {
			return this.sqlMapClient.queryForList(SqlName.queryProjectAccount, projectId);
		} catch (SQLException e) {
			log.error("Query project account error",e);
			return Collections.emptyList();
		}
	}

	public int deleteProjectAccount(int projectId) throws SQLException {
		return this.sqlMapClient.delete(SqlName.deleteProjectAccount,projectId);
	}


}
